<%--
  Created by IntelliJ IDEA.
  User: aiwzy
  Date: 2022/4/13
  Time: 14:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>首页</title>
</head>
<script type="text/javascript">
    alert("欢迎来到首页！")
</script>
<body>
<div style="margin: 0 auto ; width: 1000px">
<%--    <h1 id="detail" style="background-color:palegoldenrod;width: 230px; height: 80px; font-size: 30px; cursor: pointer"><a href="/pageManage?cate=1">查看新闻明细表</a></h1>--%>
    <input id="detail" type="button" value="查看新闻明细表" style="background-color:palegoldenrod;width: 230px; height: 80px; font-size: 30px; cursor: pointer">
    <input id="user" type="button" value="查看用户表" style="background-color:#b4b0f1;width: 230px; height: 80px; font-size: 30px;cursor: pointer">
    <input id="detail" type="button" value="查看评论表" style="background-color:rgb(252,132,132);width: 230px; height: 80px; font-size: 30px;cursor: pointer">
    <input id="category" type="button" value="查看新闻类别表" style="background-color:#c2eaa3;width: 230px; height: 80px; font-size: 30px;cursor: pointer">
<%--    <h1 id="user"><a href="/pageManage?cate=2">查看用户表</a></h1>--%>
<%--    <h1 id="comment"><a href="/pageManage?cate=3">查看评论表</a></h1>--%>
<%--    <h1 id="category"><a href="/pageManage?cate=4">查看新闻类别表</a></h1>--%>
</div>


</body>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    $(document).ready(function (){
        $("#detail").click(function (){
            $.ajax(
                {
                    url:"/pageManage",//处理分页查询的中间站
                    data:{'cate':'1'},//1进detail表
                    method:"get",
                    async:false,
                    dataType:"text",
                    success:function (data){
                        // console.log("aaaaaaa")
                        // var text =data.responseText;
                        // console.log(data)
                        if(data == 1){
                            alert("欢迎进入新闻详细页面！")
                            window.location.href="/detail";//处理detail表页面的数据
                        }

                    },
                    error:function (data) {

                        // var text = data.responseText;
                        // if(text == 1){
                        //     var s= "到达detail表！！！"
                        //     document.getElementById("suc").innerHTML=s;
                        //     window.location.href="http://localhost:8080//detail";
                        // }
                    }
                }
            )
        })
        $("#user").click(function (){
            $.ajax(
                {
                    url: "/pageManage",
                    data: {
                        cate:2
                    },
                    method:"get",
                    async: true,
                    dataType: "text",
                    success:function (date){
                        if(date==1){
                            window.location.href="/user";
                        }
                    }
                }
            )
        })

        $("#category").click(function (){
            $.ajax(
                {
                    url: "/pageManage",
                    data: {
                        cate:4
                    },
                    method:"get",
                    async: true,
                    dataType: "text",
                    success:function (date){
                        if(date==1){
                            window.location.href="/category";
                        }
                    }
                }
            )
        })
    })
</script>
</html>
